﻿using System;
using System.Windows.Forms;
using System.IO;

namespace Warl
{
    public partial class SettingsForm : Form
    {
        Main _main;

        public SettingsForm(Main form)
        {
            InitializeComponent();
            //
            this._main = form;
        }

        private void SettingsForm_Load(object sender, EventArgs e)
        {
            load();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog browse = new FolderBrowserDialog();
            browse.Description = "Locate your World of Warcraft folder.";
            if ((browse.ShowDialog() == DialogResult.OK) && smartSenseSearch.validWoW(browse.SelectedPath))
            {
                textBox1.Text = browse.SelectedPath;
                Settings.wowPath = browse.SelectedPath;
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            new SmartSense().ShowDialog();
            load();
            button3_Click(null, null);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (smartSenseSearch.validWoW(textBox1.Text))
            {
                textBox2.Text = smartSenseSearch.realmlistSearch(textBox1.Text);
                Settings.realmlistPath = textBox2.Text;
            }
        }

        #region Functions

        private void load()
        {
            textBox1.Text = Settings.wowPath;
            textBox2.Text = Settings.realmlistPath; 
        }

        #endregion
    }
}
